import React, { Component } from 'react';
import { Text, TouchableOpacity } from 'react-native';
import { Actions } from 'react-native-router-flux';
import styled from 'styled-components';
import { logout } from '../../api';
import { removeToken } from '../../utils/auth';

export default class Myself extends Component {
  logout = () => {
    logout().then(res => {
      Actions.app();
      removeToken();
    });
  };
  render() {
    return (
      <Container>
        <TouchableOpacity onPress={() => this.logout()}>
          <Text>退出登录</Text>
        </TouchableOpacity>
      </Container>
    );
  }
}

const Container = styled.View`
  width: 100%;
  height: 100%;
  background-color: white;
`;
